package com.bjqh.edu.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.bjqh.edu.Base.AppConstants;
import com.bjqh.edu.Bean.Class;
import com.bjqh.edu.R;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/9/30.
 */

public class MyOrderAdapter extends BaseAdapter {
    private List<Class.RowsBean> list;
    private Context ctx;
    private ViewHolder holder;
    String name;
    String time;


    public MyOrderAdapter(Context ctx, List<Class.RowsBean> list) {
        this.ctx = ctx;
        this.list = list;

    }


    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View view, ViewGroup parent) {

        if (view == null) {
            view = LayoutInflater.from(ctx).inflate(R.layout.item_my_order, null);
            holder = new ViewHolder(view);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        holder.tvTitle.setText(list.get(position).getTitle());
        holder.tvTime.setText(AppConstants.times(list.get(position).getStime()));

                if(list.get(position).getType()==1)
                {
                     name="一对一房间";

                }
         if(list.get(position).getType()==2)
        {
             name="普通大班课房间";

        }
        if(list.get(position).getType()==3)
        {
            name="互动小班课房间";

        }

               Long aLong= list.get(position).getEtime()-list.get(position).getStime();
        time=aLong/3600000+"";
holder.tvContent.setText(name+","+AppConstants.gettimedd(list.get(position).getStime())+"----"+AppConstants.gettimedd(list.get(position).getEtime())+",共"+time+"课时。");

        return view;
    }


    static


    class ViewHolder {
        @BindView(R.id.tv_time)
        TextView tvTime;
        @BindView(R.id.tv_title)
        TextView tvTitle;
        @BindView(R.id.tv_content)
        TextView tvContent;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
